<!DOCTYPE html>
<html lang="zh">

	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta http-equiv="X-UA-Compatible" content="ie=edge" />
		<title>商品结算</title>
		<link rel="stylesheet" type="text/css" href="css/index.css" />
		<link rel="stylesheet" type="text/css" href="css/weui.min.css" />
		<link rel="stylesheet" type="text/css" href="css/jquery-weui.min.css" />
		<link rel="stylesheet" href="css/ydui.css" />
		<link rel="stylesheet" href="css/demo.css" />
		<style>
			body {
				background: #f9f9f9;
			}
		</style>
	</head>

	<body>
		<div class="schooltop">
			<div class="schooltp">
				<div class="schooltp1">
					<div class="sctp1fl">
						<div class="splogin">

						</div>
					</div>
					<div class="sctp1fr">
						<div class="shopcart">
							<a class="nerr" href="shopcart.html" target="_blank">
								<img src="img/shopcrat.png" alt="" class="gwcimg" />
								<span class="gwctxt">我的购物车</span>
							</a>
						</div>
					</div>
				</div>
				<!--<div class="schooltp2">
					<p class="schoolmc">阿克苏地区库车中等职业技术学校--欢迎您</p>
				</div>-->
			</div>

		</div>
		<div class="shopCart">
			<div class="contact">
				<div class="title">
					<p class="jsaddre">收货人信息</p>
					<p class="jsadddz">
						<span class="jsxcdz">+添加地址</span>
					</p>
				</div>
				<div class="contdiv">
					<div class="contdiv1">
						<p class="jslxr"><span class="jslxr1">收货人：</span><span class="jslxr1" id='acceptname'>张三</span></p>
						<p class="jsphone"><span class="jsphone1">联系电话：</span><span class="jsphone2" id='accepttel'>13678976543</span></p>
					</div>
					<div class="contdiv2">
						<p class="jsdizhi">收货地址：<span id='acceptadd'>新疆维吾尔自治区乌鲁木齐幸福街道幸福小区</span></p>
					</div>
				</div>
			</div>
			<div class="gwcshop">
				<div id='tableHead' class="gwcshop2">
					

					<div class="gwcname">
						<p class="gwcpic">商品缩略图</p>
						<p class="gwcitem">商品名称</p>

					</div>
					<div class="guige">规格</div>
					<div class="gwcjg"><span>单价</span></div>
					<div class="gwcnum">数量</div>
					<div class="gwhj">合计</div>
					
				</div>
				<!--<div id="carsub" class="gwcshop1">
					
					<div class="gwselect"><input type="checkbox" name="" id="" value="" /></div>
					
                    	<a href="shop_detail.html" target="_blank" title="切糕新疆纯手工新疆切糕特产美食整块手工玛仁糖零食糕点500g 新疆传统切糕【大块500g*1盒】">

						<div class="gwcname">
							<p class="gwcpic"><img src="//img10.360buyimg.com/cms/s80x80_jfs/t1/117515/35/5149/418660/5eb251edEc05fae81/45ba6f462126332c.jpg" alt="" class="gwcimg1" /></p>
							<p class="gwcitem">切糕新疆纯手工新疆切糕特产美食整块手工玛仁糖零食糕点500g 新疆传统切糕【大块500g*1盒】</p>

						</div>
					</a>
					<div class="guige" title="新疆传统切糕【大块500g*1盒】">新疆传统切糕【大块500g*1盒】</div>
					<div class="gwcjg"><span>￥82.00</span></div>
					<div class="gwcnum">X2</div>
					<div class="gwhj">￥128</div>
					<div class="detele">删除</div>
				</div>
				-->

				<div class="jiesuan">
					<div class="jscon">
						
						<p class="jsconp1"><span class="gwhj1">合计：</span><span class="gwhj1" id="totalMoney">￥0</span></p>
						<p class="jiesuanbtn">
							<a  class="acolor" onclick="submitorder(this)" target="_blank">提交订单</a>
						</p>
					</div>
				</div>
			</div>
		</div>
		<div class="shopbottom">
			<div class="shopbmcon">
				<p class="schoolname">
					<a href="http://www.worlduc.com/e/default.aspx?eid=2784009" target="_blank">阿克苏地区库车中等职业技术学校</a>
				</p>
				<p class="schoolname">学校地址：阿克苏地区库车县福鸿路26号</p>
			</div>
		</div>
		<div class="adddizhi">
			<div class="adddzcon">
				<p class="closedz"><img src="img/close.png" alt="" class="closeimg" /></p>
				<p class="adddztit">添加地址</p>
				<div class="dztj">
					<div class="m-cell">
						<div class="cell-item" style="padding-left: 0;">
							<div  class="dztjsp1">收货地址:</div>
							<div class="cell-right cell-arrow">
								<input type="text" class="cell-input" style="font: 14px/30px '微软雅黑';" readonly id="J_Address2" value="新疆 乌鲁木齐市 天山区" placeholder="请选择收货地址">
							</div>
						</div>
					</div>
					<p class="dztjp1"><span class="dztjsp1">详细地址:</span><input type="text" class="dztjin1" placeholder="详细地址" /></p>
					<p class="dztjp1"><span class="dztjsp1">收货人姓名:</span><input type="text" class="dztjin1" placeholder="收货人姓名" /></p>
					<p class="dztjp1"><span class="dztjsp1">手机号码:</span><input type="number" class="dztjin1" placeholder="手机号码" /></p>
				</div>
				<p class="bcdizhi">保存地址</p>
			</div>
		</div>
	</body>

</html>
<script src="js/jquery.min.js"></script>
<script src="js/Global.js"></script>
<script src="js/jquery-1.11.0.js"></script>
<script src="js/ydui.citys.js"></script>
<script src="js/ydui.js"></script>
<script src="js/ydui.flexible.js"></script>
<script type="text/javascript" src="js/loginstate.js"></script>
<script>
	var money = 0;
	jQuery(document).ready(function() {
		loadDetail();
	});
	function loadDetail() {
		var data = JSON.parse(localStorage.getItem("shopcardata"));
		for(var i = 0; i < data.length; i++) {
			var obj = data[i];
			var normArr = getNormModel(obj.sizesq);
			var content = '<div id="child' + i + '" class="gwcshop1">' +
				'<a href="shop_detail.html?id=' + obj.goodsid + '" target="_blank" title="">' +
				'<div class="gwcname">' +
				'<p class="gwcpic"><img src="' + obj.img + '" alt="" class="gwcimg1" /></p>' +
				'<p class="gwcitem">' + obj.content + '</p>' +
				'</div>' +
				'</a>' +
				'<div class="guige" title="">' + normArr[0].typedesc + '</div>' +
				'<div class="gwcjg"><span >￥' + obj.price + '</span></div>' +
				'<div class="gwcnum" >X' + obj.count + '</div>' +
				'<div class="gwhj" id="total' + i + '">￥' + obj.money + '</div>' +
				'<input id="good' + i + '" style="display:none" value="' + obj.goodsid + '"/>' +
				'<input id="sizesq' + i + '"/ style="display:none" value="' + obj.sizesq + '">' +
				
				'</div>';
			$('#tableHead').after(content);
			$('#totalMoney').text("￥"+obj.total);
		}
		

	}
	function submitorder(obj){
		var successno = new Array();
		var data = JSON.parse(localStorage.getItem("shopcardata"));
		for(var i = 0; i < data.length; i++) {
			var obj = data[i];
			var userid = obj.user.id;
			var goodsid = obj.goodsid;
			var sizesq = obj.sizesq;
			var nums = obj.count;
			var price = obj.price;
			var money = obj.money;
			var address = $('#acceptadd').text();
			var phone = $('#accepttel').text();
			var name = $('#acceptname').text();
			$.ajax({
			type: "post",
			url: requesturl + "order/create",
			async: false,
			data: {
				"userid": userid,
				"goodsid": goodsid,
				"sizesq": sizesq,
				"nums": nums,
				"price": price,
				"money":money ,
				"address": address,
				"phone": phone,
				"name":name
			},
			xhrFields: {
				withCredentials: true
			},
			success: function(data) {
				if(data.status == "success") {
					successno[i] = data.data.orderno;
//					var child = "#child"+i;
//			        $(child).hide();
				} else {
					alert(obj.content+'提交失败！');
				}
			},
			error: function(data) {
				alert("网络原因发送失败：" + data.responseText);
			}
		});
			
		}
		if(successno.length>0){
			localStorage.setItem("ordernos",JSON.stringify(successno));
		    window.open("./cashier.html");
		}
		
	}
</script>
<script>
	! function() {
		var $target = $('#J_Address2');

		$target.citySelect({
			provance: '新疆',
			city: '乌鲁木齐市',
			area: '天山区'
		});

		$target.on('click', function(event) {
			event.stopPropagation();
			$target.citySelect('open');
		});

		$target.on('done.ydui.cityselect', function(ret) {
			$(this).val(ret.provance + ' ' + ret.city + ' ' + ret.area);
		});
	}();
</script>